**********************************************************************************************************************************************
* De Juan, Alexander: "Heterogeneous Effects of Development Aid on Violent Unrest in Post-War Countries – Village-Level Evidence from Nepal" *
**********************************************************************************************************************************************

********************
* Replication code *
********************

set more off

use "De Juan_Nepal Aid Conflict_Data_301019.dta"

*****************************
* Prepare data for analysis *
*****************************

* define panel structure

xtset vdc_code year
sort vdc_code  year
tab year, gen(year_dum)
tab dist_code, gen(dist_code_dum)

* drop VDCs with ill-defined geographical scope (individual parts not contiguous)

drop if vdc_code== 294 | vdc_code== 572 | vdc_code== 597 | vdc_code== 711 | vdc_code== 874 | vdc_code== 949 | vdc_code== 1031 
drop if vdc_code== 1104 | vdc_code== 1232 | vdc_code== 1239 | vdc_code== 1441 | vdc_code== 1494 | vdc_code== 1727 | vdc_code== 1736 
drop if vdc_code== 1765 | vdc_code== 1776 | vdc_code== 1866 | vdc_code== 2673 | vdc_code== 2773 | vdc_code== 2795 | vdc_code== 2820 
drop if vdc_code== 2823 | vdc_code== 3121 | vdc_code== 3230 | vdc_code== 3298 | vdc_code== 3331 | vdc_code== 3377 | vdc_code== 3413 
drop if vdc_code== 3535 | vdc_code== 3553 | vdc_code== 3664 | vdc_code== 3775 

* generate outcome variable

gen dum_aid_total =0
replace dum_aid_total =1 if aid_count>0
gen dum_aid_geop1 =0
replace dum_aid_geop1 =1 if aid_geop_1_count>0
gen dum_aid_geop12 =0
replace dum_aid_geop12 =1 if aid_geop_1_2_count>0

* generate explanatory variables

gen violent_event=violent_any
gen antistate_violevent=antistate_violentevent
gen other_target_violentevent=violent_nonstate
gen ln_violent_event=ln(1+violent_any)
gen ln_antistate_violevent=ln(1+antistate_violentevent)
gen ln_other_target_violentevent=ln(1+violent_nonstate)
gen violent_event_dum =0
replace violent_event_dum=1 if violent_any>0
gen antistate_violevent_dum=0
replace antistate_violevent_dum =1 if antistate_violentevent>0
gen other_target_violentevent_dum=0
replace other_target_violentevent_dum=1 if violent_nonstate>0

* generate temporal lags of explanatory variables

gen lag_violent_event=l.violent_event
gen lag_antistate_violevent=l.antistate_violevent
gen lag_other_target_violentevent=l.other_target_violentevent
gen lag_ln_violent_event =l.ln_violent_event
gen lag_ln_antistate_violevent=l.ln_antistate_violevent
gen lag_ln_other_target_violentevent=l.ln_other_target_violentevent
gen lag_dum_violent_event =l.violent_event_dum
gen lag_dum_antistate_violevent=l.antistate_violevent_dum
gen lag_dum_otherviol=l.other_target_violentevent_dum

* generate temporal lags of spatial lags of explanatory variables
gen spat_lag_allviol = l.splag_violent_any
gen spat_lag_antistateviol = l.splag_antistate_violentevent
gen spat_lag_otherviol = l.splag_violent_nonstate
gen spat_lag_ln_allviol = ln(1+spat_lag_allviol)
gen spat_lag_ln_antistateviol = ln(1+spat_lag_antistateviol)
gen spat_lag_ln_otherviol = ln(1+spat_lag_otherviol)
gen splag_allviol_dum =0
replace splag_allviol_dum =1 if splag_violent_any>0
gen splag_antistateviol_dum =0
replace splag_antistateviol_dum =1 if splag_antistate_violentevent>0
gen splag_otherviol_dum =0
replace splag_otherviol_dum =1 if splag_violent_nonstate>0
gen spat_lag_dum_allviol =l.splag_allviol_dum
gen spat_lag_dum_antistateviol=l.splag_antistateviol_dum
gen spat_lag_dum_otherviol=l.splag_otherviol_dum

* generate district-level variables

gen vdc_no =1
egen count_vdc_district = sum(vdc_no), by(dist_code year)
egen count_aiddum_district = sum(dum_aid_total), by(dist_code year)
gen share_aid_dist = count_aiddum_district/count_vdc_district
gen vdc_high_low_aid_district =0 if share_aid_dist<0.1
replace vdc_high_low_aid_district =1 if share_aid_dist>0.9
egen count_other_target_district = sum(other_target_violentevent), by(dist_code year)
gen ln_count_other_target_district = ln(1+ count_other_target_district)
egen count_state_target_district = sum(antistate_violentevent), by(dist_code year)
gen ln_count_state_target_district = ln(1+ count_state_target_district)

* label variables

label variable dum_aid_total "Aid Project"
label variable MC_VDC_failed "VDC performance fail"
label variable logpopulation "Population Size (ln)"
label variable share_indigenouspeople2011 "% Indigenous People"
label variable civilwar_total_death_pop "Deaths Civil War / Pop Size"
label variable nearest_dist_hq_distance_log "Distance DistCap (ln)"
label variable ln_meanlig "Nightlights (ln)"
label variable lag_ln_violent_event "Violent events (count, ln)"
label variable vdc_2006_present "VDC Secretary 2006"
label variable share_drinkingwater "% Access Tap Water"
label variable ethnic_fractionalization "Fractionalization"
label variable ln_violent_event "Violent Event (ln)"
label variable ln_antistate_violevent "Violent Anti-state Event (ln)"
label variable ln_other_target_violentevent "Violent Non-state Event (ln)"
label var ln_count_other_target_district "District: violence against non-state (log)"
label var ln_count_state_target_district "District: violence against state (log)"

save "De Juan_Nepal Aid Conflict_Data_301019_prepared.dta", replace

***********************
* Prepare estimations *
***********************

local controls "logpopulation share_indigenouspeople2011 share_drinkingwater civilwar_total_death_pop vdc_2006_present nearest_dist_hq_distance_log"

**********************************
* Descriptive tables and figures *
**********************************

* Summary statistics

estpost summarize ln_violent_event ln_antistate_violevent ln_other_target_violentevent dum_aid_total MC_VDC_failed ln_meanlig logpopulation share_indigenouspeople2011 share_drinkingwater civilwar_total_death_pop vdc_2006_present nearest_dist_hq_distance_log ethnic_fractionalization  
esttab using summary_stats.rtf, compress varwidth(20) cells("mean(fmt(3)) min(fmt(3)) max(fmt(3)) sd(fmt(3)) count(fmt(0))") noobs nonumber label title("Summary statistics") replace

* Plot violent events and aid over time

graph bar violent_event, over(year, label(labsize(large))) ytitle("Violent events (mean per VDC)", size(vlarge)) bar(1, color(white) lcolor(black))
graph export "plot_violence_year.png", replace
graph bar dum_aid_total, over(year, label(labsize(large))) ytitle("Violent events (mean per VDC)", size(vlarge)) bar(1, color(white) lcolor(black))
graph export "plot_aid_year.png", replace

* Plot different sources of violence

gen violent_ethnic_casts= violent_casts+ violent_ethnic
gen violent_congress_other_parties= violent_congress+ violent_oparties
graph bar violent_Maoists violent_congress_other_parties violent_Terai violent_ethnic_casts violent_ogroups violent_unidentified violent_state, legend(off) ytitle(Mean number of violent events) ascat yvaroptions(relabel(1 "Maoists" 2 "Parties" 3 "Terai" 4 "Ethnic" 5 "Other" 6 "Unknown" 7 "State"))
graph export "plot_violence_type.png", replace

***************
* Main models *
***************

* Table 1

eststo: reg ln_violent_event dum_aid_total lag_ln_violent_event MC_VDC_failed spat_lag_ln_allviol ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_violent_event dum_aid_total lag_ln_violent_event spat_lag_ln_allviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 01_aid_main_model.rtf, title("Table 1. Correlation between aid provision and violent unrest") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("OLS"  "OLS   VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.2.

eststo: reg ln_violent_event dum_aid_total lag_ln_violent_event MC_VDC_failed spat_lag_ln_allviol ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_violent_event dum_aid_total lag_ln_violent_event spat_lag_ln_allviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
eststo: reg ln_antistate_violevent dum_aid_total lag_ln_antistate_violevent spat_lag_ln_antistateviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_antistate_violevent dum_aid_total lag_ln_antistate_violevent spat_lag_ln_antistateviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
eststo: reg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 02_aid_types_violence.rtf, title("Table A.2. Correlation between aid provision and violent unrest - anti-state and non-state violence") nogaps se b(3) se(3) varwidth(23) modelwidth(5) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("All violence" "All violence" "Anti-state" "Anti-state" "Non-state" "Non-state")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Figure 5

reg ln_violent_event dum_aid_total lag_ln_violent_event MC_VDC_failed spat_lag_ln_allviol ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
estimates store all_events
reg ln_antistate_violevent dum_aid_total lag_ln_antistate_violevent spat_lag_ln_antistateviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
estimates store state_target
reg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
estimates store nonstate_target
coefplot (all_events,label(All events)) (state_target,label(Against State)) (nonstate_target,label(Against Non-State)),drop(dist_code_dum* year_dum* spat* lag* _cons) xline(0)  
graph export "plot_main_effects.png", replace

* Table A.3a.

eststo: reg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 03a_aid_temporal_trends_2periods.rtf, title("Table A.3a. Correlation between aid provision and non-state violence - 2 lags / 2 leads") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.3b.

eststo: reg ln_other_target_violentevent f1.dum_aid_total dum_aid_total l1.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent f1.dum_aid_total dum_aid_total l1.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 03b_aid_temporal_trends_1period.rtf, title("Table A.3b. Correlation between aid provision and non-state violence - 1 lag / 1 lead") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.3c.

eststo: reg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 03c_aid_temporal_trends_2leads.rtf, title("Table A.3c. Correlation between aid provision and non-state violence - 2 leads") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.3d.

eststo: reg ln_other_target_violentevent dum_aid_total l1.dum_aid_total l2.dum_aid_total  lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent dum_aid_total l1.dum_aid_total l2.dum_aid_total  lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 03d_aid_temporal_trends_2lags.rtf, title("Table A.3d. Correlation between aid provision and non-state violence - 2 lags") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Figure 6

reg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
estimates store trends_nonstate_target
xtreg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
estimates store trends_nonstate_target_fe
coefplot (trends_nonstate_target,label(Against non-state - no VDC fixed effects)) (trends_nonstate_target_fe,label(Against non-state - VDC fixed effects)), drop (lag_ln_other_target_violentevent spat_lag_ln_otherviol dist_code_dum* spat_lag_ln* MC_VDC_failed ln_meanlig year_dum* dist_code_dum* _cons `controls') vertical recast(connected) legend(position(6)) title("2 leads, 2 lags", size(large)) xlabel(1 "2 years prior" 2 "1 year prior" 3 "aid project" 4 "1 year after" 5 "2 years after") yline(0, lcolor(red))
graph save "nostate_2lags_2leads", replace
reg ln_other_target_violentevent f1.dum_aid_total dum_aid_total l1.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
estimates store trends_nonstate_target
xtreg ln_other_target_violentevent f1.dum_aid_total dum_aid_total l1.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
estimates store trends_nonstate_target_fe
coefplot (trends_nonstate_target,label(Against non-state - no VDC fixed effects)) (trends_nonstate_target_fe,label(Against non-state - VDC fixed effects)), drop (lag_ln_other_target_violentevent spat_lag_ln_otherviol dist_code_dum* spat_lag_ln* MC_VDC_failed ln_meanlig year_dum* dist_code_dum* _cons `controls') vertical recast(connected) legend(position(6)) title("1 lead, 1 lag", size(large)) xlabel(1 "1 year prior" 2 "aid project" 3 "1 year after")  yline(0, lcolor(red))
graph save "nostate_1lags_1leads", replace
reg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
estimates store trends_nonstate_target
xtreg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
estimates store trends_nonstate_target_fe
coefplot (trends_nonstate_target,label(Against non-state - no VDC fixed effects)) (trends_nonstate_target_fe,label(Against non-state - VDC fixed effects)), drop (lag_ln_other_target_violentevent spat_lag_ln_otherviol dist_code_dum* spat_lag_ln* MC_VDC_failed ln_meanlig year_dum* dist_code_dum* _cons `controls') vertical recast(connected) legend(position(6)) title("2 leads", size(large)) xlabel(1 "2 years prior" 2 "1 year prior" 3 "aid project") yline(0, lcolor(red))
graph save "nostate_2leads", replace
reg ln_other_target_violentevent dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
estimates store trends_nonstate_target
xtreg ln_other_target_violentevent dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
estimates store trends_nonstate_target_fe
coefplot (trends_nonstate_target,label(Against non-state - no VDC fixed effects)) (trends_nonstate_target_fe,label(Against non-state - VDC fixed effects)), drop (lag_ln_other_target_violentevent spat_lag_ln_otherviol dist_code_dum* spat_lag_ln* MC_VDC_failed ln_meanlig year_dum* dist_code_dum* _cons `controls') vertical recast(connected) legend(position(6)) title("2 lags", size(large))  xlabel(1 "aid project" 2 "1 year after" 3 "2 years after") yline(0, lcolor(red))
graph save "nostate_2lags", replace
graph combine "nostate_2lags_2leads" "nostate_1lags_1leads" "nostate_2leads" "nostate_2lags", cols(2)
graph export "Figure_time_trends_nostate.png", replace

* Table A.4.

collapse (sum) aid_count (mean) meanlig MC_VDC_failed (first) share_aid_dist ln_count_other_target_district, by(dist_code year)
xtset dist_code year
tab year, gen(year_dum)
gen ln_aid_total_count = ln(1+ aid_count)
gen lag_ln_aid_total_count = l.ln_aid_total_count
gen lag_share_aid_dist = l.share_aid_dist
gen ln_meanlig = ln(1+meanlig)
label var ln_count_other_target_district "Violence against non-state (log)"
label var ln_meanlig "Nightlights (ln)"
label var MC_VDC_failed "VDC performance fail (share)"
eststo: xtreg share_aid_dist ln_count_other_target_district lag_share_aid_dist ln_meanlig MC_VDC_failed year_dum*, fe r cluster(dist_code)
eststo: xtreg ln_aid_total_count ln_count_other_target_district lag_ln_aid_total_count ln_meanlig MC_VDC_failed year_dum*, fe r cluster(dist_code)
esttab using 4_aid_allocation_district_level.rtf, title("Table A.4. Determinants of aid allocation on the district level") nogaps se b(3) se(3) varwidth(35) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Year dummies =  year_dum*") mtitles("Coverage" "Intensity")  note("Standard Errors clustered per district in all models") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear
clear

* Table A.5.

use "De Juan_Nepal Aid Conflict_Data_301019_prepared.dta"

local controls "logpopulation share_indigenouspeople2011 share_drinkingwater civilwar_total_death_pop vdc_2006_present nearest_dist_hq_distance_log"
xtset vdc_code year
gen time_trend= year-2006
eststo: xtreg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig time_trend if (dum_aid_total==1 & vdc_high_low_aid_district==1) | (dum_aid_total==0 & vdc_high_low_aid_district==0), fe r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig ln_count_other_target_district time_trend if (dum_aid_total==1 & vdc_high_low_aid_district==1) | (dum_aid_total==0 & vdc_high_low_aid_district==0), fe r cluster(vdc_code)
esttab using 5_aid_violence_reduced_sample.rtf, title("Table A.5. Correlation between aid provision and non-state violence - reduced sample (districts completely included in/excluded from aid projects)") nogaps se b(3) se(3) varwidth(35) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Linear time trend =  time_trend*") mtitles("VDC FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.6.

eststo: reg ln_other_target_violentevent i.dum_aid_total##c.ethnic_fractionalization lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent i.dum_aid_total##c.ethnic_fractionalization lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 06_aid_violence_interact_fract.rtf, title("Table A.6. Correlation between aid provision and non-state violence - interaction with ethnic fractionalization") nogaps se b(3) se(3) varwidth(35) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Figure 7

reg ln_other_target_violentevent i.dum_aid_total##c.ethnic_fractionalization lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
margins, dydx(dum_aid_total) at(ethnic_fractionalization=(0 (0.1) 1))
marginsplot,  addplot(hist ethnic_fractionalization , recast(line, lpattern(dot)) bcolor(gs12) yaxis(2)  below) legend(off) title("Violence against non-state actors", size(large))
graph export "plot_interaction_effects_fractionalization_nonstate.png", replace

* Table 2

eststo: reg ln_other_target_violentevent i.dum_aid_total##i.MC_VDC_failed lag_ln_other_target_violentevent spat_lag_ln_otherviol  ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent i.dum_aid_total##i.MC_VDC_failed lag_ln_other_target_violentevent spat_lag_ln_otherviol  ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 07_aid_violence_interact_vdc_cap.rtf, title("Table 2. Correlation between aid provision and non-state violence - interaction with local institutional quality") nogaps se b(3) se(3) varwidth(35) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.7.

eststo: reg ln_violent_event dum_aid_geop1 lag_ln_violent_event MC_VDC_failed spat_lag_ln_allviol ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_violent_event dum_aid_geop1 lag_ln_violent_event spat_lag_ln_allviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
eststo: reg ln_antistate_violevent dum_aid_geop1 lag_ln_antistate_violevent spat_lag_ln_antistateviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_antistate_violevent dum_aid_geop1 lag_ln_antistate_violevent spat_lag_ln_antistateviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
eststo: reg ln_other_target_violentevent dum_aid_geop1 lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent dum_aid_geop1 lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 08_aid_types_violence_geoprecision1.rtf, title("Table A.7. Correlation between aid provision and violent unrest - anti-state and non-state violence") nogaps se b(3) se(3) varwidth(23) modelwidth(5) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("All violence" "All violence" "Anti-state" "Anti-state" "Non-state" "Non-state")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.8.

eststo: poisson violent_event dum_aid_total lag_violent_event spat_lag_allviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtpoisson violent_event dum_aid_total lag_violent_event spat_lag_allviol MC_VDC_failed ln_meanlig year_dum*, fe
eststo: poisson antistate_violevent dum_aid_total lag_antistate_violevent spat_lag_antistateviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtpoisson antistate_violevent dum_aid_total lag_antistate_violevent spat_lag_antistateviol MC_VDC_failed ln_meanlig year_dum*, fe
eststo: poisson other_target_violentevent dum_aid_total lag_other_target_violentevent spat_lag_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtpoisson other_target_violentevent dum_aid_total lag_other_target_violentevent spat_lag_otherviol MC_VDC_failed ln_meanlig year_dum*, fe
esttab using 09_aid_types_violence_nonlinear.rtf, title("Table A.8. Correlation between aid provision and violent unrest - anti-state and non-state violence - Poisson models") nogaps se b(3) se(3) varwidth(23) modelwidth(5) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("All violence" "All violence" "Anti-state" "Anti-state" "Non-state" "Non-state")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.9.

eststo: logit violent_event_dum dum_aid_total lag_dum_violent_event spat_lag_dum_allviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtlogit violent_event_dum dum_aid_total lag_dum_violent_event spat_lag_dum_allviol MC_VDC_failed ln_meanlig year_dum*, fe
eststo: logit antistate_violevent_dum dum_aid_total lag_dum_antistate_violevent spat_lag_dum_antistateviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtlogit antistate_violevent_dum dum_aid_total lag_dum_antistate_violevent spat_lag_dum_antistateviol MC_VDC_failed ln_meanlig year_dum*, fe
eststo: logit other_target_violentevent_dum dum_aid_total lag_dum_otherviol spat_lag_dum_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtlogit other_target_violentevent_dum dum_aid_total lag_dum_otherviol spat_lag_dum_otherviol MC_VDC_failed ln_meanlig year_dum*, fe
esttab using 10_aid_types_violence_logit.rtf, title("Table A.9. Correlation between aid provision and violent unrest - anti-state and non-state violence - logit models") nogaps se b(3) se(3) varwidth(23) modelwidth(5) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("All violence" "All violence" "Anti-state" "Anti-state" "Non-state" "Non-state")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Table A.10.

eststo: reg ln_violent_event dum_aid_total  MC_VDC_failed  ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_violent_event dum_aid_total  MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
eststo: reg ln_antistate_violevent dum_aid_total  MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_antistate_violevent dum_aid_total  MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
eststo: reg ln_other_target_violentevent dum_aid_total  MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum*, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent dum_aid_total  MC_VDC_failed ln_meanlig year_dum*, fe r cluster(vdc_code)
esttab using 11_aid_types_violence_nolags.rtf, title("Table A.10. Correlation between aid provision and violent unrest - anti-state and non-state violence - no lags") nogaps se b(3) se(3) varwidth(23) modelwidth(5) scalars(r2) label nodepvars indicate("Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("All violence" "All violence" "Anti-state" "Anti-state" "Non-state" "Non-state")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

*************************************************************************
* Additional robustness checks - models excluding the outlyer year 2010 *
*************************************************************************

* Main model
eststo: reg ln_violent_event dum_aid_total lag_ln_violent_event spat_lag_ln_allviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum* if year!=2010, r cluster(vdc_code)
eststo: xtreg ln_violent_event dum_aid_total lag_ln_violent_event spat_lag_ln_allviol MC_VDC_failed ln_meanlig year_dum* if year!=2010, fe r cluster(vdc_code)
esttab using 08_aid_main_model_no2010.rtf, title("Table X.1. Correlation between aid provision and violent unrest; excluding the year 2010") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("OLS"  "OLS   VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Different types of violence
eststo: reg ln_antistate_violevent dum_aid_total lag_ln_antistate_violevent spat_lag_ln_antistateviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum* if year!=2010, r cluster(vdc_code)
eststo: xtreg ln_antistate_violevent dum_aid_total lag_ln_antistate_violevent spat_lag_ln_antistateviol MC_VDC_failed ln_meanlig year_dum* if year!=2010, fe r cluster(vdc_code)
eststo: reg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum* if year!=2010, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum* if year!=2010, fe r cluster(vdc_code)
esttab using 09_aid_types_violence_no2010.rtf, title("Table X.2. Correlation between aid provision and violent unrest - anti-state and non-state violence; excluding the year 2010") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Anti-state" "Anti-state" "Non-state" "Non-state")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Developments over time
eststo: reg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum* if year!=2010, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent f2.dum_aid_total f1.dum_aid_total dum_aid_total l1.dum_aid_total l2.dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum* if year!=2010, fe r cluster(vdc_code)
esttab using 10_aid_nonstate_violence_no2010.rtf, title("Table X.3. Correlation between aid provision and non-state violence - time trends; excluding the year 2010") nogaps se b(3) se(3) varwidth(25) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Reduced sample
eststo: xtreg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum* if ((dum_aid_total==1 & vdc_high_low_aid_district==1) | (dum_aid_total==0 & vdc_high_low_aid_district==0)) &  year!=2010, fe r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent dum_aid_total lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig ln_count_other_target_district year_dum* if ((dum_aid_total==1 & vdc_high_low_aid_district==1) | (dum_aid_total==0 & vdc_high_low_aid_district==0)) &  year!=2010, fe r cluster(vdc_code)
esttab using 11_aid_violence_reduced_sample_no2010.rtf, title("Table X.4. Correlation between aid provision and non-state violence - reduced sample (districts completely included in/excluded from aid projects); excluding the year 2010") nogaps se b(3) se(3) varwidth(35) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*") mtitles("VDC FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Interaction - ethnic fragmentation
eststo: reg ln_other_target_violentevent i.dum_aid_total##c.ethnic_fractionalization lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig `controls' dist_code_dum* year_dum* if year!=2010, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent i.dum_aid_total##c.ethnic_fractionalization lag_ln_other_target_violentevent spat_lag_ln_otherviol MC_VDC_failed ln_meanlig year_dum* if year!=2010, fe r cluster(vdc_code)
esttab using 12_aid_violence_interact_fract_no2010.rtf, title("Table X.5. Correlation between aid provision and violent unrest - interaction with ethnic fractionalization; excluding the year 2010") nogaps se b(3) se(3) varwidth(35) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

* Interaction - institutional quality
eststo: reg ln_other_target_violentevent i.dum_aid_total##i.MC_VDC_failed lag_ln_other_target_violentevent spat_lag_ln_otherviol  ln_meanlig `controls' dist_code_dum* year_dum* if year!=2010, r cluster(vdc_code)
eststo: xtreg ln_other_target_violentevent i.dum_aid_total##i.MC_VDC_failed lag_ln_other_target_violentevent spat_lag_ln_otherviol  ln_meanlig year_dum* if year!=2010, fe r cluster(vdc_code)
esttab using 13_aid_violence_interact_vdc_cap_no2010.rtf, title("Table X.6. Correlation between aid provision and violent unrest - interaction with local institutional quality; excluding the year 2010") nogaps se b(3) se(3) varwidth(35) modelwidth(7) scalars(r2) label nodepvars indicate("Temporal lag = lag_*" "Spatial lag = spat_*" "Year dummies =  year_dum*" "District dummies=dist_code_dum*") mtitles("Dist FE" "VDC FE")  note("Standard Errors clustered per VDC in all models ") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) replace
eststo clear

clear

**************************************************
* Descriptive plot on cross-country associations *
**************************************************

use "De Juan_Nepal_Aid_Conflict_Cross-Country_data_301019" 
twoway lfitci ln_acled ln_aid_count,  ciplot(rline) blpattern(dash)  || scatter ln_acled ln_aid_count , mlabel(country) xtitle("Aid projects (log)") ytitle("Violent events (log)")  legend(order(1 2))
graph export "Figure_Scatter_Cross-Country.png", as(png) replace

clear
